import request from '../../request/index.js'

/**
 * @param {Object} code
 * 登录
 */
export function login(code){
	let url = '/api/login/wx/app'
	let params = {code}
	return request.get(url,{params})
}

/**
 * 调试登录
 * @param {Object} userId
 */
export function testLogin(userId){
	let url = `/api/login/test`
	let params = {userId}
	return request.get(url,{params})
}

/**
 * 注册
 * @param {Object} topUserId
 * @param {Object} avatar
 * @param {Object} name
 * @param {Object} openId
 * @param {Object} unionId
 */
export function register(topUserId,avatar,name,openId,unionId){
	let url = `/api/login/wx/register`
	let data = {
		topUserId,avatar,name,openId,unionId,Loading:true
	}
	return request.post(url,data)
}

/**
 * @param {Object} encryptedData
 * @param {Object} iv
 * 获取用户信息
 */
export function getShareInfo(encryptedData,iv){
	let url = '/api/login/share/user'
	let params = {
		encryptedData,iv
	}
	return request.get(url,{params})
}